import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

typedef DialogTapCallback = void Function();

/// 日历按钮通用组件
///
/// example：
///
/// CalendarBtnIcon(onTap: () => Get.dialog(_buildShowDatePicker(context))) 打开日历
///
class CalendarBtnIcon extends StatelessWidget {
  final DialogTapCallback? onTap;
  final DateTime? calenderDay;

  const CalendarBtnIcon({super.key, this.calenderDay, this.onTap});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      child: IconButton(
        icon: Stack(
          alignment: Alignment.center,
          children: [
            Image.asset('assets/images/home/calendar_rectangle.png', width: 70.w, height: 70.h),
            Positioned(
              bottom: 1,
              child: Text((calenderDay ?? DateTime.now()).day.toString(), style: TextStyle(fontSize: 40.sp, color: Colors.redAccent)),
            )
          ],
        ),
        onPressed: onTap,
      ),
    );
  }
}
